package resources;

import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
@ManagedBean
@SessionScoped
public class CourseBean {
private String name;
private ArrayList<String> courses=new ArrayList<String>();
private ArrayList<Integer> index=new ArrayList<Integer>();
public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
	addName(name);
}
public ArrayList<String> getCourses() {
	return courses;
}
public void setCourses(ArrayList<String> courses) {
	this.courses = courses;
}

private void addName(String name1){
	System.out.println("hello student");
	courses.add(name1);
}
public void testMethod(Object o)
{
	String str = (String)o;
	System.out.println("String is: "+str);
	
	index.add(courses.indexOf(o));
}
public void deleteCourses(ActionEvent e){
	System.out.println("Cursul zero"+ courses.get(0));
	/*int j;
	for(int i=0;i<index.size();i++)
	{ j=index.get(i);
	     courses.remove(j);
	     index.clear();}*/
	
	System.out.println("index de zero: "+ index.get(0));
	/*if(index.get(0)==0)
	courses.remove(0);
	else if(index.get(0)==1)
		courses.remove(1);*/
	for(int i=0;i<index.size();i++){
		int indexOfCourse = index.get(i);
		courses.remove(indexOfCourse);
	}
	index.clear();
	System.out.println("Course deleted");
}
}
